package com.yvde.test.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yvde.test.service.UserService;

public class Userlistservlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	UserService userService = new UserService();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sPageNo = request.getParameter("pageNo");
		int pageNo = sPageNo!=null && sPageNo.matches("\\d+")?Integer.parseInt(sPageNo):1;
		try {
			request.setAttribute("page", userService.query(pageNo, 5));
			request.getRequestDispatcher("/user/list.jsp").forward(request, response);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
 